package com.pktechan.manage.service.impl;


import com.pktechan.manage.base.BaseMapper;
import com.pktechan.manage.base.BaseServiceImpl;
import com.pktechan.manage.dao.StatusFlowMapper;
import com.pktechan.manage.entity.CommissionWithdrawFlow;
import com.pktechan.manage.entity.StatusFlow;
import com.pktechan.manage.enumeration.CommissionWithdrawStatusEnum;
import com.pktechan.manage.enumeration.StatusFlowTypeEnum;
import com.pktechan.manage.service.StatusFlowService;
import com.pktechan.manage.utils.SystemConstants;
import com.pktechan.manage.vo.StatusFlowVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("statusFlowService")
public class StatusFlowServiceImpl extends BaseServiceImpl<StatusFlow> implements StatusFlowService {

    private static final Logger logger = LoggerFactory.getLogger(StatusFlowServiceImpl.class);

    @Autowired
    private StatusFlowMapper statusFlowMapper;

    /**
     * 由业务类实现
     *
     * @return
     */
    @Override
    public BaseMapper<StatusFlow> getBaseMapper() {
        return statusFlowMapper;
    }

    /**
     * 查询状态流水表列表
     * @param statusFlowVo
     * @return
     */
    @Override
    public List<StatusFlowVo> getStatusFlowVoList(StatusFlowVo statusFlowVo) {
        return statusFlowMapper.getStatusFlowVoList(statusFlowVo);
    }

    /**
     * 添加流水
     * @param businessType
     * @param BusinessNo
     * @param stateOld
     * @param stateCur
     * @param exeCustId
     */
    @Override
    public void statusFlowSave(Integer businessType,Integer BusinessNo,Integer stateOld,Integer stateCur,Integer exeCustId){
        logger.debug("增加一条状态流水：业务种类="+ businessType+"业务表ID="+BusinessNo+"变更前状态="+stateOld+"变更后状态="+stateCur+"操作人id="+exeCustId+"");
        StatusFlow statusFlow = new StatusFlow();
        statusFlow.setBusinessType(businessType);
        statusFlow.setBusinessNo(BusinessNo);
        statusFlow.setStateOld(stateOld);
        statusFlow.setStateCur(stateCur);
        statusFlow.setExeCustId(exeCustId);
        statusFlow.setExeRemark(CommissionWithdrawStatusEnum.getNameByCode(stateCur));
        logger.debug("添加状态流水");
        statusFlowMapper.save(statusFlow);
    }
}
